//
//  ByCellShopCarSettleAddress.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/27.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellShopCarSettleAddress.h"

@implementation ByCellShopCarSettleAddress
{
    
    UILabel     *_nameLabel;        // 姓名
    UILabel     *_mobileLabel;      // 手机
    UILabel     *_addressLabel;     // 地址
    
    UIImageView *_locationView;     // 定位图标
    UIView      *_sepLine;          // 分隔
    UIImageView *_arrowView;        // 箭头
    UIImageView *_colorLine;        // 彩条
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        [self setupUI];
        [self layout];
    }
    return self;
}

- (void)setupUI {
    
    // 名字
    _nameLabel = [UILabel new];
    _nameLabel.font = FONT(16);
    [self.contentView addSubview:_nameLabel];
    
    // 手机
    _mobileLabel = [UILabel new];
    _mobileLabel.font = FONT(16);
    _mobileLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_mobileLabel];
    
    // 地址
    _addressLabel = [UILabel new];
    _addressLabel.numberOfLines = 0;
    _addressLabel.font = FONT(14);
    [self.contentView addSubview:_addressLabel];
    
    // 定位图标
    _locationView = [[UIImageView alloc] init];
    _locationView.image = [UIImage imageNamed:@"定位图标"];
    [self.contentView addSubview:_locationView];
    
    // 分割
    _sepLine = [[UIView alloc] init];
    _sepLine.backgroundColor = BY_LINE_COLOR;
    [self.contentView addSubview:_sepLine];
    
    // 双箭头
    _arrowView = [[UIImageView alloc] init];
    _arrowView.image = [UIImage imageNamed:@"双箭头"];
    [self.contentView addSubview:_arrowView];
    
    // 彩条
    _colorLine = [[UIImageView alloc] init];
    _colorLine.image = [UIImage imageNamed:@"地址彩条"];
    [self.contentView addSubview:_colorLine];
}

- (void)layout {
    
    [_locationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.size.mas_equalTo(CGSizeMake(20, 20));
        
        make.centerY.equalTo(_addressLabel);
    }];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@10);
        make.left.equalTo(_locationView.mas_right).offset(10);
        make.height.equalTo(@20);
    }];
    [_mobileLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.height.equalTo(_nameLabel);
        make.right.equalTo(self.contentView).offset(-10);
        make.left.equalTo(_nameLabel.mas_right).offset(10);
    }];
    [_arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.right.equalTo(@-15);
        
        make.centerY.equalTo(_locationView);
    }];
    [_sepLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@20);
        make.right.equalTo(_arrowView.mas_left).offset(-15);
        make.width.equalTo(@1);
        make.centerY.equalTo(_locationView);
    }];
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nameLabel.mas_bottom).offset(10);
        make.left.equalTo(_nameLabel);
        make.right.equalTo(_sepLine.mas_left).offset(-10);
    }];
    [_colorLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self.contentView);
        make.top.equalTo(_addressLabel.mas_bottom).offset(10);
        make.height.equalTo(@5);
    }];
}


- (void)setModel:(ByModelAddress *)model {
    
    _model = model;
    
    _nameLabel.text = _model.name;
    _mobileLabel.text = _model.mobile;
    _addressLabel.text = _model.address;
    
}

@end
